from django.http import HttpResponse
from ...models.configs import Configs

import json


def config_get(request):
    key = request.GET.get('key')
    try:
        con_obj = Configs.objects.get(marker=key)
    except:
        res_mes = {
            "code": 1,
            "message": "获取配置失败！"
        }
        res_mes_json = json.dumps(res_mes, ensure_ascii=False)
        return HttpResponse(res_mes_json)
    
    res_mes = {
        "code": 0,
        "data": con_obj.config_json
    }
    res_mes_json = json.dumps(res_mes, ensure_ascii=False)
    return HttpResponse(res_mes_json)

